package com.baidu.mapapi;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.List;

public class MKLocationManager
{
  public static final int MK_COORDINATE_BAIDU09 = 2;
  public static final int MK_COORDINATE_GCJ = 1;
  public static final int MK_COORDINATE_WGS84 = 0;
  public static final int MK_GPS_PROVIDER = 0;
  public static final int MK_NETWORK_PROVIDER = 1;
  private Location a = null;
  private Location b = null;
  private long c = 864000L;
  private long d = 0L;
  private List<LocationListener> e = new ArrayList();
  private List<SensorEventListener> f = new ArrayList();
  private SensorEventListener g = null;

  void a()
  {
    this.b = null;
  }

  boolean a(SensorEventListener paramSensorEventListener)
  {
    if (this.f.size() == 0)
    {
      if (!d())
        return false;
      if (this.f.add(paramSensorEventListener))
        return true;
      e();
      return false;
    }
    return this.f.add(paramSensorEventListener);
  }

  boolean a(BMapManager paramBMapManager)
  {
    if (paramBMapManager == null);
    do
    {
      return false;
      Mj.q = true;
      this.e.clear();
    }
    while (Mj.InitLocationCC() != 1);
    return true;
  }

  void b()
  {
    Mj.DisableProviderCC(0);
    Mj.DisableProviderCC(1);
  }

  void b(SensorEventListener paramSensorEventListener)
  {
    this.f.remove(paramSensorEventListener);
    if (this.f.size() == 0)
      e();
  }

  void c()
  {
    Location localLocation = getLocationInfo();
    long l = System.currentTimeMillis();
    int j;
    if ((localLocation != null) && (l - this.d >= 1000L * this.c))
    {
      this.d = l;
      j = 0;
    }
    while (j < this.e.size())
    {
      ((LocationListener)this.e.get(j)).onLocationChanged(localLocation);
      this.b = localLocation;
      j++;
      continue;
      if ((this.b == null) || (localLocation == null) || (localLocation.distanceTo(this.b) >= 0.1D) || (localLocation.getAccuracy() != this.b.getAccuracy()) || (localLocation.getBearing() != this.b.getBearing()) || (localLocation.getSpeed() != this.b.getSpeed()) || (localLocation.getAltitude() != this.b.getAltitude()))
      {
        this.d = l;
        for (int i = 0; i < this.e.size(); i++)
        {
          ((LocationListener)this.e.get(i)).onLocationChanged(localLocation);
          this.b = localLocation;
        }
      }
    }
  }

  boolean d()
  {
    SensorManager localSensorManager = (SensorManager)Mj.e.getSystemService("sensor");
    if (localSensorManager == null)
      return false;
    Sensor localSensor = localSensorManager.getDefaultSensor(3);
    if (localSensor == null)
      return false;
    this.g = new SensorEventListener()
    {
      public void onAccuracyChanged(Sensor paramAnonymousSensor, int paramAnonymousInt)
      {
        for (int i = 0; i < MKLocationManager.a(MKLocationManager.this).size(); i++)
          ((SensorEventListener)MKLocationManager.a(MKLocationManager.this).get(i)).onAccuracyChanged(paramAnonymousSensor, paramAnonymousInt);
      }

      public void onSensorChanged(SensorEvent paramAnonymousSensorEvent)
      {
        for (int i = 0; i < MKLocationManager.a(MKLocationManager.this).size(); i++)
          ((SensorEventListener)MKLocationManager.a(MKLocationManager.this).get(i)).onSensorChanged(paramAnonymousSensorEvent);
      }
    };
    return localSensorManager.registerListener(this.g, localSensor, 3);
  }

  public boolean disableProvider(int paramInt)
  {
    if ((paramInt != 0) && (paramInt != 1));
    while (Mj.DisableProviderCC(paramInt) == 0)
      return false;
    if (paramInt == 0)
      Mj.p = false;
    while (true)
    {
      return true;
      if (paramInt == 1)
        Mj.q = false;
    }
  }

  void e()
  {
    if (this.g == null);
    SensorManager localSensorManager;
    do
    {
      return;
      localSensorManager = (SensorManager)Mj.e.getSystemService("sensor");
    }
    while ((localSensorManager == null) || (localSensorManager.getDefaultSensor(3) == null));
    localSensorManager.unregisterListener(this.g);
  }

  public boolean enableProvider(int paramInt)
  {
    if ((paramInt != 0) && (paramInt != 1));
    while (Mj.EnableProviderCC(paramInt) == 0)
      return false;
    if (paramInt == 0)
      Mj.p = true;
    while (true)
    {
      return true;
      if (paramInt == 1)
        Mj.q = true;
    }
  }

  public Location getLocationInfo()
  {
    Bundle localBundle = Mj.GetGPSStatus();
    if (localBundle == null)
      return null;
    if (localBundle.getInt("t") == 1)
    {
      this.a = new Location("network");
      this.a.setLatitude(localBundle.getFloat("y"));
      this.a.setLongitude(localBundle.getFloat("x"));
      this.a.setAccuracy(localBundle.getInt("r"));
    }
    while (true)
    {
      return this.a;
      this.a = Mj.a.a;
      this.a.setLatitude(localBundle.getFloat("y"));
      this.a.setLongitude(localBundle.getFloat("x"));
    }
  }

  public Bundle getNotifyInternal()
  {
    return Mj.GetNotifyInternal();
  }

  public void removeUpdates(LocationListener paramLocationListener)
  {
    this.e.remove(paramLocationListener);
  }

  public void requestLocationUpdates(LocationListener paramLocationListener)
  {
    this.e.add(paramLocationListener);
  }

  public void setLocationCoordinateType(int paramInt)
  {
    Mj.c = paramInt;
    Mj.SetLocationCoordinateType(paramInt);
  }

  public boolean setNotifyInternal(int paramInt1, int paramInt2)
  {
    if ((paramInt1 >= paramInt2) && (paramInt2 >= 0))
    {
      this.c = paramInt1;
      return Mj.SetNotifyInternal(paramInt1, paramInt2) == 1;
    }
    return false;
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.baidu.mapapi.MKLocationManager
 * JD-Core Version:    0.6.2
 */